home *** CD-ROM | disk | FTP | other *** search
- head 1.5;
- access;
- symbols
- VER_0_3:1.5
- VER_0_2:1.4;
- locks; strict;
- comment @# @;
-
-
- 1.5
- date 95.03.24.11.43.35; author coulter; state Exp;
- branches;
- next 1.4;
-
- 1.4
- date 95.03.10.02.42.22; author coulter; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 95.02.19.16.06.41; author coulter; state Exp;
- branches;
- next 1.2;
-
- 1.2
- date 95.02.19.10.13.26; author coulter; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 95.02.18.08.36.38; author coulter; state Exp;
- branches;
- next ;
-
-
- desc
- @install a directory on the hard disk.
- @
-
-
- 1.5
- log
- @Checkin version for 0.3 distribution.
- @
- text
- @# !/bin/ksh
- USAGE=\
- 'USAGE: install_dir [ -d config_prefix ] dest_dir_path mount_path map_to_path
- If dest_dir_path is actually a directory below mount_path, duplicate
- directories below map_to_path to make dest_dir_path be below
- map_to_path.
- '
- # (C) Copyright 1995 by Michael Coulter. All rights reserved.
- # Basically we create on or for a directory many simple links and then use
- # check_links or check_one_link to fix up the link.
- set -P # print absolut hw path
-
- # Define std functions
-
- ISOFS_UTIL_DIR="${ISOFS_UTIL_DIR:-/usr/src/linux/fs/isofs/Utils}"
- . "$ISOFS_UTIL_DIR/ksh_fns"
-
- # Process parameters
-
- CONFIG_PREFIX=""
- if [ $# -ge 2 -a "$1" = "-d" ]
- then
- shift # done with -d
- CONFIG_PREFIX="$1"; shift
- fi
- if [ $# -ne 3 ]
- then
- echo "$USAGE" >&2
- echo "$0 Expected 3 parameters, got $#" >&2
- exit 1
- fi
- DEST_DIR_PATH="$1"; shift
- MOUNT_PATH="$1"; shift
- MAP_TO_PATH="$1"; shift
- if [ ! -d "$DEST_DIR_PATH" ]
- then
- echo "$USAGE" >&2
- echo "$DEST_DIR_PATH is not a directory" >&2
- exit 1
- fi
- if [ "$DEST_DIR_PATH" = "${DEST_DIR_PATH#$MAP_TO_PATH}" ]
- then
- if [ "$DEST_DIR_PATH" = '.' -o "$DEST_DIR_PATH" = '/' ]
- then
- exit 0
- fi
- echo "$USAGE" >&2
- echo "$DEST_DIR_PATH is not below $MAP_TO_PATH" >&2
- exit 1
- fi
-
- # Set variables
-
- TEMP_DIR="install_dir.$$"
- HERE="$PWD"
-
- # Do it
-
- ##echo "install_dir: $DEST_DIR_PATH"
- check_cmd 1 cd "$DEST_DIR_PATH"
- THERE="$(pwd -H)"
- ##echo "install_dir: THERE is $THERE"
- # If THERE is not below MOUNT_PATH, there is nothing to do
- if [ "$THERE" != "${THERE#$MOUNT_PATH}" ]
- then
- # EQUIV= the mirror of THERE.
- if [ "$MAP_TO_PATH" = "/" ]
- then
- EQUIV="${THERE#$MOUNT_PATH}"
- else
- EQUIV="${MAP_TO_PATH}${THERE#$MOUNT_PATH}"
- fi
- ##echo "install_dir: EQUIV is $EQUIV"
-
- # We need to install THERE. Do we need to install its parent?
- cd "$(dirname "$EQUIV")"
- if [ "$PWD" != "${PWD#${MOUNT_PATH}}" ]
- then
- ##echo "install_dir: " install_dir "$(dirname "$EQUIV")" "$MOUNT_PATH" "$MAP_TO_PATH"
- check_cmd 20 install_dir -d "$CONFIG_PREFIX" "$(dirname "$EQUIV")" "$MOUNT_PATH" "$MAP_TO_PATH"
- fi
- cd "$HERE"
-
- DEST_PARENT="$(dirname "$DEST_DIR_PATH")"
- if [ "$DEST_PARENT" != "$(dirname "$EQUIV")" ]
- then
- # We need to install DEST_DIR_PATH. Do we need to install its parent?
- cd "$DEST_PARENT"
- if [ "$PWD" != "${PWD#${MOUNT_PATH}}" ]
- then
- check_cmd 20 install_dir -d "$CONFIG_PREFIX" "$DEST_PARENT" "$MOUNT_PATH" "$MAP_TO_PATH"
- fi
- fi
-
- # Install EQUIV
- if [ ! -d "$EQUIV" ]
- then
- ##echo "install_dir: Processing $DEST_DIR_PATH path $EQUIV " >&2
- echo "should be a directory." >&2
- exit 21
- fi
-
- check_cmd 2 cd "$(dirname "$THERE")"
- THERE_PARENT="$(pwd -H)"
- cd "$HERE"
- if [ -L "$EQUIV" ]
- then
- check_cmd 5 cd "$DEST_PARENT"
- rm -f "$TEMP_DIR"
- check_cmd 6 mkdir "$TEMP_DIR"
- check_cmd 7 cd "$THERE"
- for FILE in * .??* .[^.]
- do
- if [ -e "$FILE" -o -L "$FILE" ]
- then
- ##echo install_dir: ln -s "${THERE}/${FILE}" "${DEST_PARENT}/${TEMP_DIR}/${FILE}"
- ln -s "${THERE}/${FILE}" "${DEST_PARENT}/${TEMP_DIR}/${FILE}"
- fi
- done
- cd "$HERE"
- check_cmd 8 rm -f "$EQUIV"
- check_cmd 12 cd "$DEST_PARENT"
- check_cmd 9 mv "$TEMP_DIR" "$EQUIV"
- check_cmd 10 cd "$HERE"
- ##echo install_dir: check_cmd 11 check_links -d "$CONFIG_PREFIX" "$EQUIV"
- check_cmd 11 check_links -d "$CONFIG_PREFIX" "$EQUIV"
- fi
- if [ -L "$DEST_DIR_PATH" ]
- then
- check_cmd 13 rm -f "$DEST_DIR_PATH"
- check_cmd 14 ln -s "$EQUIV" "$DEST_DIR_PATH"
- fi
- fi
- cd "$HERE"
- @
-
-
- 1.4
- log
- @Checkin files modified to make version 0.2
- @
- text
- @d8 1
- @
-
-
- 1.3
- log
- @Checkpoint version 0.1
- @
- text
- @d2 2
- a3 1
- USAGE='USAGE: install_dir dest_dir_path mount_path map_to_path
- d18 7
- d79 1
- a79 1
- check_cmd 20 install_dir "$(dirname "$EQUIV")" "$MOUNT_PATH" "$MAP_TO_PATH"
- d90 1
- a90 1
- check_cmd 20 install_dir "$DEST_PARENT" "$MOUNT_PATH" "$MAP_TO_PATH"
- d124 2
- a125 1
- check_cmd 11 check_links "$EQUIV"
- @
-
-
- 1.2
- log
- @checkpoint file.
- @
- text
- @d7 2
- d70 1
- a70 1
- echo "install_dir: " install_dir "$(dirname "$EQUIV")" "$MOUNT_PATH" "$MAP_TO_PATH"
- @
-
-
- 1.1
- log
- @Checkpoint version before fixing /usr/bin install
- @
- text
- @d7 6
- d32 1
- a32 1
- if [ "$DEST_DIR_PATH" = '.' ]
- d43 1
- d48 2
- a49 2
- ## echo "install_dir: $DEST_DIR_PATH"
- cd "$DEST_DIR_PATH"
- d51 2
- d55 9
- d65 8
- d74 12
- a85 3
- cd "$DEST_PARENT"
- THERE_PARENT="$(pwd -H)"
- if [ "$THERE_PARENT" != "${THERE_PARENT#$MOUNT_PATH}" ]
- d87 3
- a89 6
- install_dir "$DEST_PARENT" "$MOUNT_PATH" "$MAP_TO_PATH"
- if [ $? -ne 0 ]
- then
- echo "${0}: unable to install directory $DEST_DIR_PATH" >&2
- exit 1
- fi
- d91 2
- a92 1
- cd "$DEST_PARENT"
- d94 2
- a95 1
- if [ "$THERE_PARENT" != "${THERE_PARENT#$MOUNT_PATH}" ]
- d97 18
- a114 2
- echo "Something is wrong $DEST_PARENT is below $MOUNT_PATH" >&2
- exit 1
- d118 2
- a119 4
- rm "$DEST_DIR_PATH"
- mkdir "$DEST_DIR_PATH"
- cd "$DEST_DIR_PATH"
- duplicate_dir "$THERE" "$MOUNT_PATH" "$MAP_TO_PATH"
- @
-